<?PHP session_start();
	include '../database_config.php';
	include '../global_functions.php';
	include '../global.php';
	$sessioncl = new s_SessionKlasse();
	if($sessioncl->isLogedIn()){
				
?>
<!DOCTYPE HTML>
<html lang = "en">
	<head>
		<meta charset = "UTF-8">
		<link href = "stylesheet/stylemain.css" type="text/css" rel = "stylesheet">
		<script src = "js/script.js"> 
		</script>
		<title>Wintersporttag</title>
	</head>
	<body>
		<div id = "titleBar">
			<img src = "img/ass_logo.png" alt = "ASS" id = "assLogo"/>
			<div id="slideshow">
				<div>
					<img src="slideshow/slide1.png" class="slideimg">
				</div>
				<div>
					<img src="slideshow/slide2.jpg" class="slideimg">
				</div>
				<div>
					<img src="slideshow/slide3.png" class="slideimg">
				</div>
				<div>
					<img src="slideshow/slide4.jpg" class="slideimg">
				</div>
				<div>
					<img src="slideshow/slide5.png" class="slideimg">
				</div>
			</div>
		<form method = "post" action = "../logout.php">
		<input type="submit" value = "Logout" id = "logout"> 
		</form>
		</div>
		<div id = "navigationBar">
			<script language="JavaScript">
			<!--the script
				function change(URL){
					parent.sideiFrame.location=URL;
				}
				
			-->
			</script>
			<?PHP
				$connection = mysql_connect($DB_HOST, $DB_USERNAME, $DB_PASSWORD);
			
			if(!$connection){
				/*Wenn keine Verbindung besteht */
				echo "Es konnte keine Verbindung zum Datenbank Server hergestellt werden!<br/>";
				echo "Wenden sie sich an den Systemadministrator!<br/>";
				echo "Error: " . mysql_error();
			}else{
				$database_connection = mysql_select_db($DB_DATENBANKNAME);
				if(!$database_connection){
					/*Fehler ausgabe wenn datenbank nicht geöffnet werden kann*/
					echo "Konnte Datenbank nicht öffnen!<br/>";
					echo "Bitte wenden sie sich an den Systemadministrator!</br>";
					echo "Error: " . mysql_error();
				}else{/*Wenn datenbank geöffnet werden kann*/
					$bid = $sessioncl->getBid();

					mysql_set_charset("utf8");

					$check = mysql_query("SELECT A_AUSGEWAEHLT, BID FROM benutzer WHERE BID = $bid");
					$check_fe = mysql_fetch_object($check);
					if($check_fe->A_AUSGEWAEHLT == NULL){
					$list = mysql_query("SELECT AID, PROJEKTNAME, MAX_TEILNEHMER FROM Aktivitaeten");
					while($listobject = mysql_fetch_object($list)){
						echo "<div>";
						echo "<a class = \"naviButton\" href=\"aktivitaetbeschreibung.php?AID=$listobject->AID\" target=\"iFrame\" onClick =\"javascript:change('sidebar.php?AID=$listobject->AID')\" >$listobject->PROJEKTNAME</a>";
						echo "</div>";
					}
					}else{
						$list = mysql_query("SELECT AID, PROJEKTNAME, MAX_TEILNEHMER FROM Aktivitaeten WHERE AID =$check_fe->A_AUSGEWAEHLT");
						$listobject = mysql_fetch_object($list);
						echo "<div>";
						echo "<a class = \"naviButton\" href=\"aktivitaetbeschreibung.php?AID=$listobject->AID\" target=\"iFrame\" onClick =\"javascript:change('sidebar.php?AID=$listobject->AID')\" >$listobject->PROJEKTNAME</a>";
						echo "</div>";
					}
				}
				mysql_close($connection);
			}
			?>
			</div>
			
			
		<iframe src = "willkommen.php" name = "iFrame" id = "mainFrame">
			
		</iframe>
		<iframe src="sidebar.php" scrolling = "no" name = "sideiFrame" id = "sideFrame">
			
		</iframe>
	</body>
</html>
<?PHP
			}else{
				echo "Du musst dich erst einloggen!";
				echo "<meta http-equiv=\"refresh\" content=\"2; URL=../$LOGIN_SEITE_NAME\">";
			}
			unset($sessioncl);
?>

